package com.liuhengjia.aiknowledgebase.config;

import lombok.RequiredArgsConstructor;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.client.advisor.QuestionAnswerAdvisor;
import org.springframework.ai.moonshot.MoonshotChatModel;
import org.springframework.ai.ollama.OllamaChatModel;
import org.springframework.ai.vectorstore.VectorStore;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 模型配置类
 */
@Configuration
@RequiredArgsConstructor
public class ChatClientConfig {
    private final OllamaChatModel ollamaChatModel;
    private final MoonshotChatModel moonshotChatModel;
    private final VectorStore vectorStore;

    /**
     * 聊天客户端 Bean 对象
     *
     * @return ChatClient
     */
    @Bean
    public ChatClient chatClient() {
        return ChatClient.builder(moonshotChatModel)
                .defaultSystem("你是我的企业知识库AI客服助手，请帮我解答我提出的相关问题")
                .defaultAdvisors(
                        new QuestionAnswerAdvisor(vectorStore)
                )
                .build();
    }
}
